package orz.itrip.biz.timerInterrupt;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import orz.itrip.mapper.HotelOrderMapper;


import javax.annotation.Resource;


@Component
public class TimerInterrupt {

    @Resource
    private HotelOrderMapper hotelOrderMapper;

    /**
     * 每天12点自动退房
     */
    @Scheduled(cron = "0 0 12 * * ?")
    public void automaticCheckOut(){
        int success = hotelOrderMapper.automaticallyCheckOut();
        int update = hotelOrderMapper.updateTempStore();
        if (success>0) {
            System.out.println("自动退房成功");
        }
    }

    /**
     * 15分钟未付款自动取消订单
     */
    @Scheduled(cron = "0 0/15 * * * ?")
    private void cancelAutomatically(){
        int success = hotelOrderMapper.cancelAutomatically();
        if (success>0) {
            System.out.println("未付款订单自动取消");
        }
    }
}
